import unittest,time

from selenium.webdriver import Keys
from selenium.webdriver.common.by import By
from selenium import webdriver
class A3mall(unittest.TestCase):
    def setUp(self) -> None:
        self.driver=webdriver.Edge()
        self.driver.get('http://10.59.9.12:7001/')
        # 窗口最大化
        self.driver.maximize_window()
    def tearDown(self) -> None:
        time.sleep(3)
        self.driver.quit()

    def test_a3mall_login(self):
        # 点击登录
        self.driver.find_element(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a').click()
        # 输入账号
        self.driver.find_element(By.NAME,'username').send_keys('13012558376')
        # 输入密码
        self.driver.find_element(By.NAME,'password').send_keys('123456Aa')
        time.sleep(8)
        # 点击登录
        self.driver.find_element(By.CLASS_NAME,'finish-btn').click()
        time.sleep(3)
        dy1=self.driver.find_element(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a').text
        print("断言1：",dy1)
        time.sleep(1)
        dy2=self.driver.find_element(By.XPATH,'/html/body/div[4]/a[2]').text
        print("断言2:",dy2)
        time.sleep(1)
        dy3=self.driver.find_element(By.XPATH,'/html/body/div[5]/div[2]/div[1]/div[2]/div[2]/ul/li[4]/span').text
        dy31=dy3.replace('¥ ','')
        print("断言3：",dy31)
        time.sleep(1)


    def test_a3mall_price(self):
        self.test_a3mall_login()
        self.driver.find_element(By.XPATH,'/html/body/div[3]/div[2]/ul/li[1]/a').click()
        a=self.driver.find_element(By.CLASS_NAME,'search-input')
        a.send_keys('宋牌')
        # 回车
        a.send_keys(Keys.ENTER)
        self.driver.find_element(By.XPATH,'//img[@src="/uploads/images/20250620/67e1bd127f10d17039e45464df4c460a.jpg"]').click()
        dy4=self.driver.find_element(By.XPATH,'/html/body/div[4]/a[4]').text
        time.sleep(2)
        print("断言4，",dy4)
        b=self.driver.find_element(By.ID,'store_nums')
        b.clear()
        b.send_keys('2')
        self.driver.find_element(By.ID,'add-cart').click()
        self.driver.find_element(By.CLASS_NAME,'nav-settcart').click()
        dy5=self.driver.find_element(By.XPATH,'/html/body/div[4]/div[1]/a[2]').text
        time.sleep(1)
        print("断言5：",dy5)
        self.driver.find_element(By.NAME,'id[]').click()
        self.driver.find_element(By.CLASS_NAME,'ask-btn').click()
        self.driver.find_element(By.ID,'address-834').click()
        self.driver.find_element(By.ID,'order-button').click()
        dy6=self.driver.find_element(By.XPATH,'/html/body/div[4]/div[1]/a[2]').text
        print("断言6：",dy6)
        time.sleep(3)
        self.driver.find_element(By.XPATH,'/html/body/div[4]/div[3]/p/a').click()
        dy7=self.driver.find_element(By.XPATH,'/html/body/div[5]/div[2]/div/div[2]/table[2]/tbody/tr[6]/td[2]/div[2]/a').text
        print("断言7：",dy7)
        time.sleep(3)
        dy8=self.driver.find_element(By.XPATH,'/html/body/div[5]/div[2]/div/div[4]/div/div[1]/div[2]/span[2]').text
        dy81=dy8.replace('￥','')
        print("断言8：",dy81)


if __name__ == '__main__':
    unittest.main()